1   package jrre;
2   
3   import jrre.instructionset.methodinvocation.*;
4   import jrre.instructionset.objects.*;
5   import jrre.api.java.lang.reflect.*;
6   import java.util.*;
7   
8   public class MethodArea {
9       
10      private static HashMap hashMap = new HashMap();
11      private static jrre.gui.MethodAreaGui methodAreaGui;
12      private int classCount=0;
13  
14      public MethodArea(){
15  	    super();
16  
17          /*
18          if(JRRE.guiOn()){
19              methodAreaGui = new jrre.gui.MethodAreaGui();
20          }
21          */
22      }
23  
24      static {
25          if(JRRE.guiOn()){
26              methodAreaGui = new jrre.gui.MethodAreaGui();
27          }
28      }
29  
30      public static void doneLoading(){
31          if(JRRE.guiOn())
32              methodAreaGui.refresh();
33      }
34      
35      public void addingClass(String className){
36  	    hashMap.put(className, null);
37      }
38      
39      public static void addClass(jrre.api.java.lang.Class classToAdd){
40  	    hashMap.put(classToAdd.getFullyQualifiedName(),classToAdd);
41  
42          if(JRRE.guiOn()){
43              methodAreaGui.addClass(classToAdd);
44          }
45      }
46  
47      public static jrre.api.java.lang.Class getClass(String fullyQualifiedName){
48          
49          jrre.api.java.lang.Class toReturn;
50  
51          if(!containsClass(fullyQualifiedName)){
52  
53              if(JRRE.getVerbose())
54                  System.out.println("loading: "+fullyQualifiedName);
55  
56              toReturn = jrre.classloader.ClassLoader.loadClass(fullyQualifiedName);
57  
58              if(JRRE.guiOn()){
59                  methodAreaGui.refresh();
60              }
61  
62              // Execute <cinit> method in the class.
63              MethodEntry initMethod = toReturn.getMethod("<clinit>()V");
64  
65              if(initMethod != null){
66                  StackFrame initMethodFrame = initMethod.getStackFrame();
67  
68                  // Push current instruction back on instruction stream.
69                  boolean returnNull = false;
70                  Stack.restoreLastInstruction();
71                  jrre.instructionset.Instruction current = Stack.getNextInstruction();
72                  if(current instanceof GetStatic ||
73                     current instanceof InvokeStatic ||
74                     current instanceof jrre.instructionset.push.Ldc ||
75                     current instanceof jrre.instructionset.typecasting.CheckCast ||
76                     current instanceof jrre.instructionset.objects.New) {
77  
78                      Stack.restoreLastInstruction();
79                      returnNull = true;
80                  }
81  
82                  //System.out.println("\t\t\tDone execing init: "+initMethodFrame);
83                  jrre.Stack.push(initMethodFrame, "<clinit>()V::"+fullyQualifiedName);
84  
85                  if(returnNull)
86                      return null;
87              }
88  
89  	        return toReturn;
90          }
91          else {
92      	    toReturn = (jrre.api.java.lang.Class)hashMap.get(fullyQualifiedName);
93  	        return toReturn;
94          }
95      }
96  
97      public static boolean containsClass(String fullyQualifiedName){
98  	    return hashMap.containsKey(fullyQualifiedName);
99      }
100     
101     
102 }
103 
This page was automatically generated by Maven